;;; +company.el --- Initialization and mode setting.

;;; Homepage:
;; https://company-mode.github.io

;;; Commentary:
;; Framework for text completion.

;;; Code:

(use-package company
  :ensure
  :hook
  (prog-mode . company-mode)
  :bind
  (:map company-mode-map
	("<backtab>" . company-yasnippet)
	("<tab>" . company-indent-or-complete-common)
	("TAB" . company-indent-or-complete-common))
  (:map company-active-map
        ("<backtab>" . company-select-previous)
	("<mouse-4>" . company-select-previous)
	("<mouse-5>" . company-select-next)
	("M-h" . company-show-doc-buffer)
	("<tab>" . company-select-next)
	("TAB" . company-select-next)
	("SPC" . company-abort))
  :init
  (setq company-tooltip-align-annotations t
	company-async-redisplay-delay 0
	company-backends '((company-capf :with company-yasnippet)
			   company-files)
	company-tooltip-minimum-width 0
	company-abort-on-unique-match t
	company-selection-wrap-around t
	company-minimum-prefix-length 1
	company-tooltip-idle-delay 0
	company-tooltip-limit 15
	company-echo-delay 0
	company-idle-delay 0)

  (unless (display-graphic-p)
    (setq company-format-margin-function nil))
  :config
  (set-face-attribute 'company-tooltip-common nil
		      :weight 'bold)

  (set-face-attribute 'company-tooltip-common-selection nil
		      :weight 'bold)

  (set-face-attribute 'company-tooltip-mouse nil
		      :background (face-attribute 'company-tooltip-selection :background)
		      :weight 'bold)

  (set-face-attribute 'company-tooltip-scrollbar-thumb nil
		      :background (face-attribute 'company-tooltip-common :foreground))

  (set-face-attribute 'company-tooltip-scrollbar-track nil
		      :background (face-attribute 'tooltip :background))

  (set-face-attribute 'company-tooltip-selection nil
		      :weight 'bold))

(provide '+company)

;;; +company.el ends here
